<template>
  <create-view
    :loading="loading"
    :body-style="{ height: '100%'}">
    <flexbox
      direction="column"
      align="stretch"
      class="crm-create-container">
      <flexbox class="crm-create-header">
        <div style="flex:1;font-size:17px;color:#333;">{{ title }}</div>
        <img
          class="close"
          src="@/assets/img/task_close.png"
          @click="hidenView" >
      </flexbox>
      <div class="crm-create-flex">
        <create-sections title="基本信息">
          <flexbox
            direction="column"
            align="stretch">
            <div class="crm-create-body">
              <el-form
                ref="crmForm"
                :model="crmForm"
                label-position="top"
                class="crm-create-box">
                <el-form-item
                  v-for="(item, index) in crmForm.crmFields"
                  :key="item.key"
                  :prop="'crmFields.' + index + '.value'"
                  :class="{ 'crm-create-block-item': item.showblock, 'crm-create-item': !item.showblock }"
                  :rules="crmRules[item.key]"
                  :style="{'padding-left': getPaddingLeft(item, index), 'padding-right': getPaddingRight(item, index)}">
                  <div
                    slot="label"
                    style="display: inline-block;">
                    <div style="margin:5px 0;font-size:12px;word-wrap:break-word;word-break:break-all;">
                      {{ item.data.name }}
                    </div>
                  </div>
                  <!-- 员工 和部门 为多选（radio=false）  relation 相关合同商机使用-->
                  <component
                    :is="item.data.formType | typeToComponentName"
                    :value="item.value"
                    :index="index"
                    :item="item"
                    :is-valid-all="isValidAll"
                    :relation="item.relation"
                    :radio="false"
                    :disabled="item.disabled"
                    @value-change="fieldValueChange"/>
                </el-form-item>
              </el-form>

            </div>
          </flexbox>
        </create-sections>
      </div>

      <div class="handle-bar">
        <el-button
          class="handle-button"
          @click.native="hidenView">取消</el-button>
        <el-button
          class="handle-button"
          type="primary"
          @click.native="saveField(false)">保存</el-button>
      </div>
    </flexbox>
  </create-view>
</template>
<script type="text/javascript">
import {
  mapGetters
} from 'vuex'
import crmTypeModel from '@/views/customermanagement/model/crmTypeModel'
import CreateView from '@/components/CreateView'
import CreateSections from '@/components/CreateSections'
import {
    queryFollowRecordContentFieldsAPI,
    crmSettingRecordListAPI,
    queryBusinessFollowRecordContentFieldsAPI
} from '@/api/customermanagement/common'
import {
    crmCustomerSave,
    crmCustomerQueryContacts,
    crmCustomerRecordSave,
    crmCustomerLastRecord
} from '@/api/customermanagement/customer'
import {
  crmBusinessQueryContactsAPI,
  crmBusinessRecordSave,
  crmBusinessLastRecord
} from '@/api/customermanagement/business'
import { filedGetField, filedValidates } from '@/api/customermanagement/common'
import {
  regexIsCRMNumber,
  regexIsCRMMoneyNumber,
  regexIsCRMMobile,
  regexIsCRMEmail,
  objDeepCopy,
  timestampToFormatTime,
  numberAdd, numberSub,numberMul,numberDiv
} from '@/utils'

import { isArray } from '@/utils/types'

import {
  XhInput,
  XhDataApi,
  XhTextarea,
  XhSelect,
  XhMultipleSelect,
  XhDate,
  XhDateTime,
  XhUserCell,
  XhStructureCell,
  XhFiles,
  CrmRelativeCell
} from '@/components/CreateCom'

export default {
  name: 'CrmCreateView', // 所有新建效果的view
  components: {
    CreateView,
    CreateSections,
    XhInput,
    XhDataApi,
    XhTextarea,
    XhSelect,
    XhMultipleSelect,
    XhDate,
    XhDateTime,
    XhUserCell,
    XhStructureCell,
    XhFiles,
    CrmRelativeCell,
  },
  filters: {
    /** 根据type 找到组件 */
    typeToComponentName(formType) {
      if (
        formType == 'text' ||
        formType == 'number' ||
        formType == 'floatnumber' ||
        formType == 'mobile' ||
        formType == 'email'
      ) {
        return 'XhInput'
      } else if (formType == 'textarea') {
        return 'XhTextarea'
      } else if (formType == 'select' || formType == 'business_status') {
        return 'XhSelect'
      } else if (formType == 'checkbox') {
        return 'XhMultipleSelect'
      } else if (formType == 'date') {
        return 'XhDate'
      } else if (formType == 'datetime') {
        return 'XhDateTime'
      } else if (formType == 'user') {
        return 'XhUserCell'
      } else if (formType == 'structure') {
        return 'XhStructureCell'
      } else if (formType == 'file') {
        return 'XhFiles'
      } else if (
        formType == 'contacts' ||
        formType == 'customer' ||
        formType == 'business'
      ) {
        return 'CrmRelativeCell'
      }
    }
  },
  props: {
    // CRM类型
    crmType: {
      type: String,
      default: ''
    },
    /**
     * save:添加、update:编辑(action_id)、read:详情、index:列表
     * relative: 相关 添加(目前用于客户等相关添加) 如果有relativeData 直接合并入上传
     */
    action: {
      type: Object,
      default: () => {
        return {
          type: 'save',
          id: '',
          data: {} // 编辑所需信息
        }
      }
    },
    cusIdName: {
      type: Object,
      default: () => {}
    },
    logDetail: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      // 标题展示名称
      loading: false,
      saveAndCreate: false, // 保存并新建
      // 自定义字段验证规则
      crmRules: {},
      // 自定义字段信息表单
      crmForm: {
        crmFields: []
      },
      customerValueBiz: [],

      // == 我的日志创建 ==
      recordContentFields: [],
      // 日志的名称
      title: '新建客户日志',
      // 可以加载出未审核通过的商机
      isValidAll: ''
    }
  },
  computed: {
    ...mapGetters(['userInfo'])
  },
  watch: {
    crmType: function(value) {
      this.crmRules = {}
      this.crmForm = {
        crmFields: []
      }
      this.getField()
    }
  },
  mounted() {
    // 获取title展示名称
    if (this.crmType == 'businessFollowRecord') {
      this.title = '新建商机日志'
      this.isValidAll = true
    }
    document.body.appendChild(this.$el)
    this.getField()
  },
  destroyed() {
    // remove DOM node after destroy
    if (this.$el && this.$el.parentNode) {
      this.$el.parentNode.removeChild(this.$el)
    }
  },
  methods: {

    // 字段的值更新
    fieldValueChange(data) {
      var item = this.crmForm.crmFields[data.index]
      item.value = data.value
      // 商机下处理商机状态
      if (this.crmType == 'followRecord') {
        if (item.data.formType == 'customer') {
          // 新建合同 选择客户 要将id交于 商机
          let businessElement = this.crmForm.crmFields.find(field => { return field.key == 'contacts_id' })
          if (item.value.length > 0) {
            businessElement.disabled = false
            var customerItem = item.value[0]
            customerItem['moduleType'] = 'customer'
            businessElement['relation'] = customerItem
            this.handleLaseRecord(customerItem)
            let params = {
              customerId: customerItem.customerId
            }
            crmCustomerQueryContacts(params).then((res) => {
              businessElement.value = res.data.list && res.data.list.length ? res.data.list : [];
            })
          } else {
            this.handleLaseRecord(item.value)
            businessElement.disabled = true
            businessElement['relation'] = {}
            businessElement.value = []
          }
        } else if (item.data.formType == 'contacts'){
          // item['relation'] = item.value
        }
      } else if (this.crmType === 'businessFollowRecord') {
        if (item.data.formType == 'customer') {
          // 选择客户时，关联商机
          let businessElement = this.crmForm.crmFields.find(field => { return field.key == 'business_name' })
          if (item.value.length > 0) {
            businessElement.disabled = false
            var customerItem = item.value[0]
            customerItem['moduleType'] = 'customer'
            businessElement['relation'] = customerItem
          } else {
            businessElement.disabled = true
            businessElement['relation'] = {}
            businessElement.value = []
          }
        } else if (item.data.formType == 'business') {
          // 选择商机名称时，关联商机联系人
          let businessElement = this.crmForm.crmFields.find(field => { return field.key == 'contacts_id' })
          if (item.value.length > 0) {
            businessElement.disabled = false
            var businessItem = item.value[0]
            businessItem['moduleType'] = 'business'
            businessElement['relation'] = businessItem
            this.handleLaseRecord(businessItem)
            let params = {
              businessId: businessItem.businessId
            }
            crmBusinessQueryContactsAPI(params).then((res) => {
              businessElement.value = res.data.list && res.data.list.length ? res.data.list : []
            })
          } else {
            this.handleLaseRecord(item.value)
            businessElement.disabled = true
            businessElement['relation'] = {}
            businessElement.value = []
          }
        } else if (item.data.formType == 'contacts'){
          // item['relation'] = item.value
        }
      }

      // 无事件的处理 后期可换成input实现
      if (
        item.data.formType == 'user' ||
        item.data.formType == 'structure' ||
        item.data.formType == 'file' ||
        item.data.formType == 'customer' ||
        item.data.formType == 'contacts' ||
        item.data.formType == 'business'
      ) {
        this.$refs.crmForm.validateField('crmFields.' + data.index + '.value')
      }
    },

    // 通过选择客户获取最近一次跟进记录，并赋值
    handleLaseRecord(value) {
      let self = this
      var lastRecordRequest = {
        followRecord: crmCustomerLastRecord,
        businessFollowRecord: crmBusinessLastRecord
      }[this.crmType]
      if (value) {
        let params = {
          typesId: value.customerId
        }
        if (this.crmType == 'businessFollowRecord') {
          params.typesId = value.businessId
        }
        lastRecordRequest(params).then(res => {
          let data = res.data ? res.data : {}
          self.recordContentFields.map(content => {
            if (content.nextValueTwo == 'AUTO') {
              let field = self.crmForm.crmFields.find(item => item.data.fieldName ==
                  content.name)
              if (!(field.value && field.value.length)) {
                field.value = data[content.name] ? data[content.name] : ''
              } else {
                field.value = ''
              }
            }
          })
          let field = this.crmForm.crmFields.find(item => item.data.fieldName == 'equipmentNum')
          field.value = data.equipmentNum
          var backgroundField = this.crmForm.crmFields.find(item => item.data.fieldName == 'background')
          backgroundField.value = data.background
        })
      } else {
        self.recordContentFields.map(content => {
          if (content.nextValueTwo == 'AUTO') {
            let field = self.crmForm.crmFields.find(item => item.data.fieldName == content.name)
            field.value = ''
          }
        })
        let field = this.crmForm.crmFields.find(item => item.data.fieldName == 'equipmentNum')
        field.value = ''
        var backgroundField = this.crmForm.crmFields.find(item => item.data.fieldName == 'background')
        backgroundField.value = ''
      }
    },

    // 获取自定义字段
    getField() {
      var getFieldRequest = {
        followRecord: queryFollowRecordContentFieldsAPI,
        businessFollowRecord: queryBusinessFollowRecordContentFieldsAPI
      }[this.crmType]
      getFieldRequest().then(res => {
        this.recordContentFields = res.data.list
        this.handleFollowRecordFields()
      })
    },

    // 跟进记录字段整理
    handleFollowRecordFields() {
      let self = this
      let contents = self.recordContentFields
      let fields = []
      crmSettingRecordListAPI().then(res => {
        if (self.crmType == 'followRecord') {
          fields = [{
            'formType': 'customer',
            'isNull': 1,
            'isDisabled': 0,
            'isUnique': 0,
            'inputTips': null,
            'fieldName': 'customer_id',
            'name': '客户名称',
            'value': ''
          }, {
            "formType": "contacts",
            "isNull": 1,
            "isDisabled": 0,
            "isUnique": 0,
            "inputTips": null,
            "fieldName": "contacts_id",
            "name": "客户联系人",
            "value": ""
          }, {
            "formType": "select",
            "isNull": 1,
            "isDisabled": 0,
            "isUnique": 0,
            "inputTips": null,
            "fieldName": "category",
            "name": "跟进方式",
            "setting": res.data,
            "value": ""
          }]
        } else if (self.crmType == 'businessFollowRecord') {
          fields = [{
            "formType": "customer",
            "isNull": 1,
            "isDisabled": 0,
            "isUnique": 0,
            "inputTips": null,
            "fieldName": "customer_id",
            "name": "客户名称",
            "value": ""
          }, {
            "formType": "business",
            "isNull": 1,
            "isDisabled": 0,
            "isUnique": 0,
            "inputTips": null,
            "fieldName": "business_name",
            "name": "商机名称",
            "value": ""
          }, {
            "formType": "contacts",
            "isNull": 1,
            "isDisabled": 0,
            "isUnique": 0,
            "inputTips": null,
            "fieldName": "contacts_id",
            "name": "商机联系人",
            "value": ""
          }, {
            "formType": "select",
            "isNull": 1,
            "isDisabled": 0,
            "isUnique": 0,
            "inputTips": null,
            "fieldName": "category",
            "name": "跟进方式",
            "setting": res.data,
            "value": ""
          }]
        }
          let arr = [];
          contents.map(item => {
            let field = {
              "formType": "textarea",
              "isNull": 0,
              "isDisabled": 0,
              "isUnique": 0,
              "inputTips": null,
              "fieldName": "",
              "name": "",
              "value": ""
            }
            if (item.nextValueOne == 'TRUE') {
              field.isNull = 1;
            }
            field.fieldName = item.name;
            field.name = item.value
            arr.push(field);
          })
          fields = fields.concat(arr);
          let field2 = [
            {
              "formType": "datetime",
              "isNull": 1,
              "isDisabled": 0,
              "isUnique": 0,
              "inputTips": null,
              "fieldName": "nextTime",
              "name": "下次联系时间",
              "value": ""
            },
            {
              "formType": "number",
              "isNull": 1,
              "isDisabled": 0,
              "isUnique": 0,
              "inputTips": null,
              "fieldName": "equipmentNum",
              "name": "设备台数",
              "value": ""
            },
            {
              'formType': 'file',
              'isNull': 0,
              "isDisabled": 0,
              "isUnique": 0,
              "inputTips": null,
              "fieldName": "batchId",
              "name": "附件",
              "value": ""
            }
          ]
          if (self.crmType == 'businessFollowRecord') {
            field2.splice(1, 0, {
              "formType": "textarea",
              "isNull": 1,
              "isDisabled": 0,
              "isUnique": 0,
              "inputTips": null,
              "fieldName": "background",
              "name": "商机背景",
              "value": ""
            })
          }
          fields = fields.concat(field2);
          if (self.logDetail) {
            if (self.crmType == 'businessFollowRecord') {
              fields[0].value = [{
                customerId: self.cusIdName.customerId,
                customerName: self.cusIdName.customerName
              }]
              fields[1].value = [{
                businessId: self.cusIdName.businessId,
                businessName: self.cusIdName.businessName
              }]
              self.getcrmRulesAndModel(fields)
              self.fieldValueChange({ index: 1, value: fields[1].value })
            } else {
              fields[0].value = [self.cusIdName]
              self.getcrmRulesAndModel(fields)
              self.fieldValueChange({ index: 0, value: fields[0].value })
            }
          } else {
            self.getcrmRulesAndModel(fields)
          }
      })
    },
    // 根据自定义字段获取自定义字段规则
    getcrmRulesAndModel(list) {
      let showStyleIndex = -1
      for (let index = 0; index < list.length; index++) {
        const item = list[index]
        showStyleIndex += 1

        /**
         * 规则数据
         */

        this.crmRules[item.fieldName] = this.getItemRulesArrayFromItem(item)
        /**
         * 表单数据
         */
        if (
          // crm相关信息特殊处理
          item.formType == 'contacts' ||
          item.formType == 'customer' ||
          item.formType == 'contract' ||
          item.formType == 'business'
        ) {
          var params = {}
          params['key'] = item.fieldName
          params['data'] = item
          // 获取 value relative 信息
          this.getParamsValueAndRelativeInfo(params, item, list)
          params['disabled'] = this.getItemDisabledFromItem(item)
          params['styleIndex'] = showStyleIndex
          params['relation'] = {}
          params['relation']['pageType'] = this.crmType
          if (item.fieldName === 'contacts_id') {
            if (this.customerValueBiz.length > 0) {
              params.disabled = false
              var customerItem = this.customerValueBiz[0]
              customerItem['moduleType'] = 'customer'
              params['relation'] = customerItem
            } else {
              params['disabled'] = this.getItemDisabledFromItem(item)
              params['styleIndex'] = showStyleIndex
              params['relation'] = {}
              params['relation']['pageType'] = this.crmType
            }
          } else if (item.fieldName === 'business_name') {
            if (this.customerValueBiz.length > 0) {
              params.disabled = false
              var customerItem = this.customerValueBiz[0]
              customerItem['moduleType'] = 'customer'
              params['relation'] = customerItem
            } else {
              params['disabled'] = this.getItemDisabledFromItem(item)
              params['styleIndex'] = showStyleIndex
              params['relation'] = {}
              params['relation']['pageType'] = this.crmType
            }
          }
          this.crmForm.crmFields.push(params)
        } else {
          var params = {}
          params['value'] = item.defaultValue || item.value || ''
          params['key'] = item.fieldName
          params['data'] = item
          params['disabled'] = item.isDisabled == 1; // 是否可交互
          params['styleIndex'] = showStyleIndex
          this.crmForm.crmFields.push(params)
        }
      }
    },
    /**
     * 获取关联项的值 和 关联信息
     */
    getParamsValueAndRelativeInfo(params, item, list) {
        params['value'] = item.value || []
        if (item.formType === 'customer') {
            this.customerValueBiz = item.value || []
        }
    },
    /**
     * 获取关联项是否可操作
     */
    getItemDisabledFromItem(item) {
      // 新建
      if (this.crmType === 'followRecord' && item.formType === 'contacts') {
        // 新建日志，默认联系人不可编辑
        return true
      } else if (this.crmType == 'businessFollowRecord' && (item.formType === 'business' || item.formType === 'contacts')) {
        return true
      }
      return item.isDisabled == 1;
    },
    /**
     * item 当行数据源
     */
    getItemRulesArrayFromItem(item) {
      var tempList = []
      // 验证必填
      if (item.isNull == 1) {
        if (item.formType == 'category') {
          tempList.push({
            required: true,
            message: item.name + '不能为空',
            trigger: []
          })
        } else {
          tempList.push({
            required: true,
            message: item.name + '不能为空',
            trigger: ['blur', 'change']
          })
        }
      }

      // 验证唯一
      if (item.isUnique == 1) {
        var validateUnique = (rule, value, callback) => {
          if ((isArray(value) && value.length == 0) || !value) {
            callback()
          } else {
            var validatesParams = {}
            validatesParams.fieldId = item.fieldId
            if (isArray(value)) {
              let postValue = ''
              if (value.length > 0) {
                if (
                  rule.item.formType == 'user' ||
                  rule.item.formType == 'structure'
                ) {
                  postValue = value
                    .map(valueItem => {
                      return rule.item.formType == 'user'
                        ? valueItem.userId
                        : valueItem.id
                    })
                    .join(',')
                } else if (rule.item.fieldName == 'categoryId') {
                  if (value && value.length) {
                    postValue = value[value.length - 1]
                  } else {
                    postValue = ''
                  }
                } else if (rule.item.formType == 'checkbox') {
                  postValue = value.join(',')
                }
              }
              validatesParams.value = postValue
            } else {
              validatesParams.value = value
            }
            if (this.action.type == 'update') {
              validatesParams.batchId = this.action.batchId
            }
            filedValidates(validatesParams)
              .then(res => {
                callback()
              })
              .catch(error => {
                callback(new Error(error.msg ? error.msg : '验证出错'))
              })
          }
        }
        tempList.push({
          validator: validateUnique,
          item: item,
          trigger:
            item.formType == 'checkbox' || item.formType == 'select'
              ? ['change']
              : ['blur']
        })
      }

      // 特殊字符
      if (item.formType == 'number') {
        var validateCRMNumber = (rule, value, callback) => {
          if (!value || value == '' || regexIsCRMNumber(value)) {
            callback()
          } else {
            callback(new Error('数字的整数部分须少于12位，小数部分须少于4位'))
          }
        }
        tempList.push({
          validator: validateCRMNumber,
          item: item,
          trigger: ['blur']
        })
      } else if (item.formType == 'floatnumber') {
        var validateCRMMoneyNumber = (rule, value, callback) => {
          if (!value || value == '' || regexIsCRMMoneyNumber(value)) {
            callback()
          } else {
            callback(new Error('货币的整数部分须少于10位，小数部分须少于2位'))
          }
        }
        tempList.push({
          validator: validateCRMMoneyNumber,
          item: item,
          trigger: ['blur']
        })
      } else if (item.formType == 'mobile') {
        var validateCRMMobile = (rule, value, callback) => {
          if (!value || value == '' || regexIsCRMMobile(value)) {
            callback()
          } else {
            callback(new Error('手机格式有误'))
          }
        }
        tempList.push({
          validator: validateCRMMobile,
          item: item,
          trigger: ['blur']
        })
      } else if (item.formType == 'email') {
        var validateCRMEmail = (rule, value, callback) => {
          if (!value || value == '' || regexIsCRMEmail(value)) {
            callback()
          } else {
            callback(new Error('邮箱格式有误'))
          }
        }
        tempList.push({
          validator: validateCRMEmail,
          item: item,
          trigger: ['blur']
        })
      }
      return tempList
    },
    // 保存草稿
    saveDraftField() {
      this.saveField(false, true)
    },
    // 保存数据
    saveField(saveAndCreate, isDraft = false) {
      this.saveAndCreate = saveAndCreate
      this.$refs.crmForm.validate(valid => {
        if (valid) {
            var params = this.getSubmiteParams(this.crmForm.crmFields)
            this.submiteParams(params)
        } else {
            return false
        }
      })
    },
    /** 上传 */
    submiteParams(params) {
      this.loading = true
      var crmRequest = this.getSubmiteRequest()
      crmRequest(params)
        .then(res => {
          this.loading = false
          this.hidenView()
          this.$message.success(
            '添加日志成功'
          )
          // 回到保存成功
          this.$emit('save-success', {
            type: this.crmType,
            data: res.data || {},
            saveAndCreate: this.saveAndCreate
          })
        })
        .catch(() => {
          this.loading = false
        })
    },
    /** 获取上传url */
    getSubmiteRequest() {
      if (this.crmType == 'followRecord') {
        return crmCustomerRecordSave
      } else if (this.crmType == 'businessFollowRecord') {
        return crmBusinessRecordSave
      }
    },
    /** 拼接上传传输 */
    getSubmiteParams(array) {
      var params = {}
      params['isEvent'] = 0;
      for (let index = 0; index < array.length; index++) {
        let item = array[index];
        if (item.key == 'customer_id') {
          if (this.crmType == 'businessFollowRecord') {
            params['customerId'] = item.value[0]['customerId'];
          } else {
            params['typesId'] = item.value[0]['customerId'];
          }
        } else if (item.key == 'business_name') {
          params['typesId'] = item.value[0]['businessId'];
        } else if (item.key == 'background') {
          params['background'] = item.value;
        } else if (item.key == 'contacts_id') {
          let str = "";
          let count = 0;
          item.value.map(data => {
              count++;
              if (count < item.value.length) {
                  str += data['contactsId'] + ",";
              } else {
                  str += data['contactsId']
              }
          })
          params['contactsIds'] = str;
        } else if(item.key == 'batchId'){
          params[item.key] = item.value[0] && item.value[0].batchId
        } else {
          params[item.key] = item.value;
        }
      }
      let fields = this.recordContentFields;
      let content = "";
      fields.map(field => {
          content += '<em>' + field.value + '</em>' + "\r\n";
          content += params[field.name] + "\r\n";
      })
      params.content = content;
      return params
    },

    hidenView() {
      this.$emit('hiden-view')
    },
    // 获取左边padding
    getPaddingLeft(item, index) {
      if (item.showblock && item.showblock == true) {
        return '0'
      }
      return item.styleIndex % 2 == 0 ? '0' : '25px'
    },
    // 获取左边padding
    getPaddingRight(item, index) {
      if (item.showblock && item.showblock == true) {
        return '0'
      }

      return item.styleIndex % 2 == 0 ? '25px' : '0'
    }
  }
}
</script>
<style lang="scss" scoped>
.crm-create-container {
  position: relative;
  height: 100%;
}

.crm-create-flex {
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1;
}

.crm-create-header {
  height: 40px;
  margin-bottom: 20px;
  padding: 0 10px;
  flex-shrink: 0;
  .close {
    display: block;
    width: 40px;
    height: 40px;
    margin-right: -10px;
    padding: 10px;
    cursor: pointer;
  }
}

.crm-create-body {
  flex: 1;
  // overflow-x: hidden;
  // overflow-y: auto;
}

/** 将其改变为flex布局 */
.crm-create-box {
  display: flex;
  flex-wrap: wrap;
  padding: 0 10px;
}

.crm-create-item {
  flex: 0 0 50%;
  flex-shrink: 0;
  // overflow: hidden;
  padding-bottom: 10px;
}

// 占用一整行
.crm-create-block-item {
  flex: 0 0 100%;
  flex-shrink: 0;
  padding-bottom: 10px;
}

.el-form-item /deep/ .el-form-item__label {
  line-height: normal;
  font-size: 13px;
  color: #333333;
  position: relative;
  padding-left: 8px;
  padding-bottom: 0;
}

.el-form /deep/ .el-form-item {
  margin-bottom: 0px;
}

.el-form /deep/ .el-form-item.is-required .el-form-item__label:before {
  content: '*';
  color: #f56c6c;
  margin-right: 4px;
  position: absolute;
  left: 0;
  top: 5px;
}

.handle-bar {
  position: relative;
  line-height: 2;
  padding-top: 5px;
  .handle-button {
    float: right;
    margin-right: 20px;
  }
}

.el-button + .el-button {
  margin-left: 0;
}

// 审核信息 里的审核类型
.examine-type {
  font-size: 12px;
  color: white;
  background-color: #fd715a;
  padding: 0 8px;
  margin-left: 5px;
  height: 16px;
  line-height: 16px;
  border-radius: 8px;
  transform: scale(0.8, 0.8);
}

</style>
